package demo1;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;
public class CardList {
    private static final String[] SUITS = {"♦","♥","♠","♣"};
    public static List<Card> buyCards(){
        List<Card> list = new ArrayList<>();
        for(int i = 0; i<SUITS.length; i++){
            for(int j = 0; j < 13; j++){
                String suit = SUITS[i];
                int rank = j;
                Card card = new Card(SUITS[i],j );
                list.add(card);
            }
        }return list;
    }
    //洗牌
    public static void shuffle(List<Card> list){
        Random random = new Random();
        for(int i = list.size()-1; i > 0;i--){
            int index = random.nextInt(i);
        }
    }


    public static void main(String[] args) {
        List<Card> list = buyCards();
        System.out.println(list);
        List<Card> hand1 = new ArrayList<>();
        List<Card> hand2 = new ArrayList<>();
        List<Card> hand3 = new ArrayList<>();
        List<List<Card>> hand = new ArrayList<>();//存放hand1,hand2,hand3 的列表hand
        hand.add(hand1);
        hand.add(hand2);
        hand.add(hand3);
        //发牌
        for(int i = 0; i < 5; i++){
            for(int j = 0; j < 3; j++) {
                Card card = list.remove(0);
                hand.get(j).add(card);
            }
        }
        System.out.println("第一个人的牌"+hand.get(0));
        System.out.println("第二个人的牌"+hand.get(1));
        System.out.println("第三个人的牌"+hand.get(2));

    }
}
